Skip to content

Conversation

@afrdbaig7
Copy link

Fixes #3611

Problem

Graphite could crash with a WGPU out-of-memory error during normal usage.

The root cause was repeated allocation of overlay textures instead of reusing existing ones.
Each frame or update created new GPU textures, causing GPU memory usage to grow continuously until WGPU failed.

This resulted in:

GPU out-of-memory crashes

Increasing memory usage over time

Unstable rendering behavior during longer sessions

Solution

Overlay textures are now cached and reused instead of being recreated repeatedly.

By reusing existing GPU textures, unnecessary allocations are avoided and GPU memory usage remains stable.
The save behavior and rendering logic remain unchanged — only texture lifecycle management is corrected.

Changes

Introduced caching for overlay textures

Prevented repeated GPU texture allocations

Ensured existing textures are reused where appropriate

Testing

Built the project locally

Reproduced the out-of-memory crash before the fix

Verified GPU memory usage remains stable after the change

Confirmed no regressions in rendering behavior

@timon-schelling
Copy link
Member

Thanks for the contribution.

I was never able to reproduce the issue, but we should do this anyway.
But I would like if TargetTexture was turned into a proper abstraction (not just making the fields pub). It should represent a texture + view that is reusable with a given size. I would suggest a ensure_size function that creates a new texture and view if the new size is != the current size. replacing the logic in render_vello_scene_to_target_texture.

@afrdbaig7 If you feel comfortable/able to do that, that would be great, otherwise I will take this over at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Crash in desktop RC2 from basic use

2 participants